//
//  HTClassTextViewEx.swift
//  QuitSmokingApp
//  
//  Created by wealon on 2024.
//  QuitSmokingApp.
//  
    
import UIKit
import Foundation

extension UITextView {
    
    private static let var_placeholderTag = 20240202
    
    var var_placeholder: String {
        set {
            if let var_lb = viewWithTag(UITextView.var_placeholderTag) as? UILabel {
                var_lb.text = newValue
            } else {
                let var_lb = UILabel()
                var_lb.tag = UITextView.var_placeholderTag
                var_lb.font = font
                var_lb.numberOfLines = 0
                var_lb.textColor = .lightGray
                var_lb.text = newValue
                addSubview(var_lb)
                setValue(var_lb, forKey: "_placeholderLabel")
            }
        }
        get {
            let var_lb = value(forKey: "_placeholderLabel") as? UILabel
            return var_lb?.text ?? ""
        }
    }
}
